<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <!--<form action="">
        限制此输入框只能输入数字
        <input type="text" pattern="^[0-9]*$">
        <input type="submit" value="提交">
    </form>-->
</body>
</html>
<script>

function caiShuZi(x,y){
    var i = Math.ceil(Math.random()*(y - x) + x);
    console.log(i)
    alert("猜数字，您有三次机会")
    for(j=2;j>=0;j--){
        var result = prompt("请输入0-100间的数字","0-100");
        console.log(result);
        if(result==i){
            alert("恭喜您，答对了")
            break;
        }
        else if(result>i){
            alert("太大了"+"您还有"+j+"次机会")
        }
        else{
            alert("太小了"+"您还有"+j+"次机会")
        }
     }
    
}
caiShuZi(0,100)


   
</script>
